import 'package:flutter/material.dart';
import '../pages/Tabs.dart';
import '../pages/News.dart';
import '../pages/NewsContent.dart';

//配置路由
final Map<String,Function> routes={
      '/':(context)=>Tabs(),
      '/news':(context)=>NewsPage(), 
      '/newsContent':(context)=>NewsContent()     
};
//固定写法 
var onGenerateRoute=(RouteSettings settings) {      
      final String? name = settings.name; 
      final Function? pageContentBuilder = routes[name];
      if (pageContentBuilder != null) {
        if (settings.arguments != null) {
          final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context, arguments: settings.arguments));
          return route;
        }else{
            final Route route = MaterialPageRoute(
              builder: (context) =>
                  pageContentBuilder(context));
            return route;
        }
      }
};